﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MementoClient.Interfaces;
using MementoClientConnectorInterfaces;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Reflection;
using System.IO;

namespace MementoClient.Classes
{
    internal class ClientConnectorRetriever : IClientConnectorRetriever
    {
        [ImportMany(typeof(IMementoClientConnector))]
#pragma warning disable 649
        private IEnumerable<IMementoClientConnector> clientConnectors;
#pragma warning restore 649

        public IEnumerable<IMementoClientConnector> Retrieve()
        {
            var catalog = new DirectoryCatalog(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
            CompositionContainer container = new CompositionContainer(catalog);
            container.ComposeParts(this);
            return clientConnectors;
        }
    }
}
